package com.tarena.lbs.common.exception;

import com.tarena.lbs.common.response.StatusCode;
import lombok.Getter;

@Getter
public class ServiceException extends RuntimeException {
    private final Integer code;
    private StatusCode statusCode;

    // 必须指定 code
    public ServiceException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    // 使用枚举（推荐）
    public ServiceException(StatusCode statusCode) {
        super(statusCode.getMessage());
        this.code = statusCode.getCode();
        this.statusCode = statusCode;
    }

    // 使用枚举但自定义消息
    public ServiceException(StatusCode statusCode, String message) {
        super(message);
        this.code = statusCode.getCode();
        this.statusCode = statusCode;
    }
}